﻿using System;
using System.Collections.Generic;

namespace GenericTypeDelegate
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Easy Generic Type Delegate");
            GenricTypeOne<int> genricTypeOne = GetValueMultiTen;
            Console.WriteLine(genricTypeOne(10));

            Console.WriteLine("返回KeyValue Pair");
            GenericTypeTwo<string, int> genericTypeTwo = KeyValuePairMaker;
            Console.WriteLine(genericTypeTwo("Hello", 100).Value) ;


        }


        static int GetValueMultiTen(int value) => value * 10;

        static KeyValuePair<string, int> KeyValuePairMaker(string key, int value)
        {
            KeyValuePair<string, int> keyValuePair = new KeyValuePair<string, int>(key, value);
            return keyValuePair;
        }

    }

    //定义泛型委托 两个参数
    public delegate KeyValuePair<T1, T2> GenericTypeTwo<T1, T2>(T1 t1, T2 t2);

    //一个参数
    public delegate T GenricTypeOne<T>(T t1);
}
